/**
 * 添加用户
 * @author dlfming
 * date 2018/06/06 19:33
 */

"use strict";
define(['app', "config/pathConfig", "layer"], function (app, pathConfig, layer) {
    app.registerController('ctrl.perManager.permission', function ($scope, $http, DTOptionsBuilder, DTColumnDefBuilder, $state) {
        $http.get(pathConfig.backstagePath.getPath() + "/permission").then(function (response) {
            $scope.per = response.data.data;
        });

        $scope.dtColumnDefs = [
            DTColumnDefBuilder.newColumnDef(10).notSortable()
        ];

        $scope.delete = function (permissionId) {
            layer.confirm('确定删除吗？', {
                icon: 2,
                title: '删除提示',
                btn: ['确定', '取消']
            }, function () {
                $http.delete(pathConfig.backstagePath.getPath() + "/permission/" + permissionId).then(function (response) {
                    if (response.status === 200) {
                        layer.msg('删除成功！', {icon: 1});
                    } else if (response.status === 500) {
                        layer.msg("服务器错误！", {icon: 2});
                    }
                    $state.reload("index.permission");
                }, function (error) {
                    console.error(error);
                })
            })

        }


    })
})
